#! /usr/bin/env python
# -*- coding: utf-8 -*-

"""

Test-as-you-code script for pySkySim.

:History:
Created on Wed Jan 21 13:01:10 2015

@author: azzollini
"""

from __future__ import absolute_import, unicode_literals, division, print_function
from pdb import set_trace as stop

import numpy as np

from pySkySim import ExpDisk, Star, Background, sed, losvd

def test0():
    """Test-as-you-code script."""
    
    # Positions and wavelengths at which we are evaluating the Sky Scene.
    
    Pos = (np.arange(10),np.arange(10)) # just a prop
    wavel = np.arange(10)
    
    # Scene:
    #   - star: an M0 star with a flux of 1 mJy at 10 um, and with 
    #       vlos=-100 km/s.
    #
    #   - galaxy: an exponential disk with a flat rotation curve and constant
    #     velocity dispersion. SED: Black-Body, Redshift = 2.
    #
    #   - slowly varying background with temp = 40 K.
    
    
    starM0 = Star(Cen=(0.5,0.5),flux=1.E-3,wref=10.,sptype='M0',vel=-100.)
    
    # Cen: Position
    # h : disk scale length
    # q : axis ratio
    # pa : position angle
    # c : 0 (diskiness/boxiness)
    
    galaxy = ExpDisk(h=0.1,Cen=(0.,0.),q=0.5,pa=35.,c=0)
    
    SEDpars = {'flux':5.E-3,'wref':10.,'Temp':100.}
    
    galaxy.get_SED(sed.BBSed(**SEDpars))
    
    VMAPpars = {'v':200.,'Cen':(0.,0.),'pa':35.,'q':0.5,'c':0}
    
    galaxy.get_velmap(losvd.Flatdisk(**VMAPpars)) 
    
    # we change our mind and change the scale length of the disk
    
    galaxy.h = 0.2
    
    
    # we print on screen the properties of our model star, and galaxy
    
    print(starM0)
    stop()
    print(galaxy)
    stop()
    
    scene = starM0 + galaxy + Background(temp=40.)
    print(scene)
    stop()
    
    # We plot the scene within a window and spectral range.
    
    scene.plot2D(window=[],specwin=[])
    
    # We plot the spectrum of the scene within a window and spectral range.
    
    scene.plotspec(window=[],specwin=[])
    
    # we evaluate the scene at "Pos" and "wavel"
    evaluated = scene(Pos,wavel,time=1.)
    
    stop()
    
if __name__ == '__main__': test0()